package com.shenzhenai.it_hei_ma.a05threadmethod2;

/**
 * @author huangzehui
 * @date 2025/8/27 12:56 周三
 * @description 多线程&JUC-07-线程的优先级
 * https://www.bilibili.com/video/BV1LG4y1T7n2?spm_id_from=333.788.player.switch&vd_source=e07cc8cc94eb22bd76722071b03cd199&p=7
 */
public class ThreadDemo {

    public static void main(String[] args) {
        /*
        setPriority(int newPriority) 设置线程的优先级
            优先级只是抢占cpu的执行概率问题，值越大，优先抢占到cpu执行的概率越大
        final int getPriority() 获取线程的优先级
         */

        MyRunnable mr = new MyRunnable();
        Thread t1 = new Thread(mr, "飞机");
        Thread t2 = new Thread(mr, "坦克");

        t1.setPriority(1);
        t2.setPriority(10);

        System.out.println(t1.getPriority());
        System.out.println(t2.getPriority());


        System.out.println(Thread.currentThread().getPriority());


        t1.start();
        t2.start();
    }

}
